package com.zkas.canalefectivo;


import android.os.Bundle;
import android.app.Activity;
//import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.content.Intent;

public class LoginActivity extends Activity {

	EditText txtUserName;
    EditText txtPassword;
    Button btnLogin;
    Button btnCancel;
    
	public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
        txtUserName=(EditText)this.findViewById(R.id.txtUname);
        txtPassword=(EditText)this.findViewById(R.id.txtPwd);
        btnLogin=(Button)this.findViewById(R.id.btnLogin);

        txtUserName.setText("marcebil@gmail.com");
        txtPassword.setText("marcelo1");
        
        btnLogin.setOnClickListener(new OnClickListener() {		
	        @Override
	        public void onClick(View v) {
	         // TODO Auto-generated method stub
	          
	        	// aca debe conectarse con el servidor y comprobar que usuario/password estan ok. 
	         //if((txtUserName.getText().toString()!="") && (txtPassword.getText().toString()!="") ) { 
	        if (true) {	        	 
	                Toast.makeText(LoginActivity.this, "Login Successful",Toast.LENGTH_LONG).show();
	        		sendMessage(txtUserName.getText().toString(), txtPassword.getText().toString());
	               } else{
	                Toast.makeText(LoginActivity.this, "Invalid Login",Toast.LENGTH_LONG).show();
	               }	          
	        }
	       });
	}        

	/*
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.login, menu);
		return true;
	}
	*/
	public void sendMessage(String user, String pwd) {
	    Intent intent = new Intent(this, BillsActivity.class);
	    /*
	    EditText editText = (EditText) findViewById(R.id.edit_message);
	    String message = editText.getText().toString();
	   	*/
	    //String message = "marcebil@gmail.com";
	    intent.putExtra(EXTRA_MESSAGE, user);	
	    startActivity(intent);
	}
}
